package com.atstudent.gmall.product.controller;

import com.atstudent.gmall.common.result.Result;
import com.atstudent.gmall.common.service.FileUploadService;
import com.atstudent.gmall.common.service.impl.FileUploadServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * 图片上传至minio
 * @ClassName：FileUploadController
 * @Dexcription
 * @Author 薛有朋
 * @CreatDate 2024/11/23 13:11
 **/
@RestController
@RequestMapping(value = "/admin/product")
public class FileUploadController {

    //注入进来 因为不在同一个包下 用不了 所以在common模块 配置类中把他提前纳入到spring容器中
    @Autowired
    private FileUploadService fileUploadService;

    /**
     * 图片上传至minio
     * @Author 薛有朋
     * @Date 2024/11/23 16:10
     **/
    @PostMapping(value = "/fileUpload")
    public Result<String> upload(@RequestParam(value = "file") MultipartFile multipartFile){
        String imageUrl = fileUploadService.upload(multipartFile);
        return Result.ok(imageUrl);
    }


}
